package com.kmproject.haifu.mvp.ui.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.beans.HousePayWayBean;

import java.util.List;

public class SecondHandPublicshBqAdapter extends BaseQuickAdapter<HousePayWayBean, BaseViewHolder> {
    int selectSexIndex=-1;
    String selectIds="";
    public SecondHandPublicshBqAdapter( @Nullable List<HousePayWayBean> data) {
        super(R.layout.housepublic_item_item, data);
    }


    public void setSelectIds(String selectIds) {
        this.selectIds = selectIds;
    }

    @Override
    protected void convert(BaseViewHolder helper, HousePayWayBean item) {
        if (!TextUtils.isEmpty(selectIds)&&selectIds.contains(item.getDictId()))
        {
            item.setSelect(true);
        }
        helper.<TextView>getView(R.id.housepublic_item_item_tv).setText(item.getName());
        helper.<TextView>getView(R.id.housepublic_item_item_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                item.setSelect(!item.isSelect());
                notifyDataSetChanged();
            }
        });
        if (item.isSelect())
        {
            helper.<TextView>getView(R.id.housepublic_item_item_tv).setTextColor(ArmsUtils.getColor(mContext,R.color.color_191919));
            helper.<TextView>getView(R.id.housepublic_item_item_tv).setBackgroundResource(R.drawable.square_yellow_bg);
        }else {
            helper.<TextView>getView(R.id.housepublic_item_item_tv).setTextColor(ArmsUtils.getColor(mContext,R.color.white));
            helper.<TextView>getView(R.id.housepublic_item_item_tv).setBackgroundResource(R.drawable.square_gray_bg);
        }
    }
}
